import { gcj02towgs84 } from "@/utils/CoordinateConvert/gcj02towgs84";
import Emberbox from "@/utils/mapbox/engine";
import { useEmberboxStore } from "../../store";

export default function addBoundary(
  emberbox: Emberbox,
  boundary: any,
  store: any
) {
  console.log("addBoundary", boundary);
  boundary.geometry.coordinates = boundary.geometry.coordinates[0];
  boundary.geometry.coordinates[0].forEach((sets: any) => {
    let asets = gcj02towgs84(sets);
    sets[0] = asets[0];
    sets[1] = asets[1];
  });
  boundary.geometry.type = "Polygon";

  let json = {
    type: "FeatureCollection",
    features: [boundary],
  };

  emberbox.geojsonManage?.addJson({
    type: "FeatureCollection",
    features: [boundary],
  });
}
